<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">主页</a>
        <a><cite lay-href="/user/list">用户列表</cite></a>
        <a><cite>用户详情</cite></a>
    </div>
</div>
<style>
    .layui-form-label {
        width:15% !important;
        margin-left:1%;
    }
    .layui-input-inline {
        width: 33% !important;
    }
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <form class="layui-form layui-form-pane">
            <div class="layui-tab layui-tab-brief">
                <input type="hidden" name="id" id="id" />
                <div class="layui-tab-content">
                    <div class="layui-form-item">
                        <label class="layui-form-label">登陆用户名</label>
                        <div class="layui-input-inline">
                            <input type="text" id="username" name="username" class="layui-input">
                        </div>
                        <label class="layui-form-label">真实姓名</label>
                        <div class="layui-input-inline">
                            <input type="text" id="realName" name="realName" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">余额</label>
                        <div class="layui-input-inline">
                            <input type="text" id="balance" name="balance" class="layui-input">
                        </div>
                        <label class="layui-form-label">账号类型</label>
                        <div class="layui-input-inline">
                            <select name="type" id="type" lay-search="">
                                <option value="1">会员</option>
                                <option value="2">代理码商</option>
                                <option value="3">码商</option>
                                <option value="4">子账号</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">总收益</label>
                        <div class="layui-input-inline">
                            <input type="text" id="totalCollProfit" name="totalCollProfit" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label">账号状态</label>
                        <div class="layui-input-inline">
                            <select name="status" id="status" lay-search="">
                                <option value="-1">待审核</option>
                                <option value="0">禁用</option>
                                <option value="1">使用中</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">总收款次数</label>
                        <div class="layui-input-inline">
                            <input type="text" id="totalCollNum" name="totalCollNum" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label">总收款金额</label>
                        <div class="layui-input-inline">
                            <input type="text" id="totalCollAmount" name="totalCollAmount" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">每天收款次数</label>
                        <div class="layui-input-inline">
                            <input type="text" id="dayMaxNum" name="dayMaxNum" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label">每天收款金额(元)</label>
                        <div class="layui-input-inline">
                            <input type="text" id="dayMaxAmount" name="dayMaxAmount" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">保证金</label>
                        <div class="layui-input-inline">
                            <input type="text" id="deposit" name="deposit" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label">费率(%)</label>
                        <div class="layui-input-inline">
                            <input type="text" id="rate" name="rate" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">邮箱</label>
                        <div class="layui-input-inline">
                            <input type="text" id="email" name="email" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label">手机号</label>
                        <div class="layui-input-inline">
                            <input type="text" id="mobile" name="mobile" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">最后登录IP</label>
                        <div class="layui-input-inline">
                            <input type="text" id="lastLoginIp" name="lastLoginIp" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label">最后登录时间</label>
                        <div class="layui-input-inline">
                            <input type="text" id="lastLoginTime" name="lastLoginTime" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">创建时间</label>
                        <div class="layui-input-inline">
                            <input type="text" id="createTime" name="createTime" autocomplete="off" class="layui-input">
                        </div>
                        <label class="layui-form-label">更新时间</label>
                        <div class="layui-input-inline">
                            <input type="text" id="updateTime" name="updateTime" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">备注信息</label>
                        <div class="layui-input-block">
                            <input type="text" id="remark" name="remark" autocomplete="off" style="width: 92%" class="layui-input"/>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block" style="padding-bottom: 20px;">
                        <a class="layui-btn" lay-href="/user/list">返回</a>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<script>
    layui.use(['admin','form'],function(){
        var form = layui.form
            ,$ = layui.$
            ,admin = layui.admin
            ,element = layui.element
            ,layer = layui.layer ;
        // 导航
        element.render('breadcrumb', 'breadcrumb');

        var id = layui.router().search.id;

        admin.req({
            type: 'get',
            url: layui.setter.baseUrl + '/user/get',
            data: {
                id : id
            },
            error: function(err){
                layer.alert(JSON.stringify(err.field), {
                    title: '错误提示'
                })
            },
            success: function(res){
                if(res.code == 0){
                    $('#id').val(res.data.id);
                    $('#codeBusId').val(res.data.codeBusId);
                    $('#agentId').val(res.data.agentId);
                    $('#username').val(res.data.username);
                    $('#status').val(res.data.status);
                    $('#type').val(res.data.type);
                    $('#realName').val(res.data.realName);
                    $('#balance').val(res.data.balance);
                    $('#dayMaxNum').val(res.data.dayMaxNum);
                    $('#dayMaxAmount').val(res.data.dayMaxAmount);
                    $('#totalCollNum').val(res.data.totalCollNum);
                    $('#totalCollAmount').val(res.data.totalCollAmount);
                    $('#totalCollProfit').val(res.data.totalCollProfit);
                    $('#email').val(res.data.email);
                    $('#mobile').val(res.data.mobile);
                    $('#deposit').val(res.data.deposit);
                    $('#rate').val((res.data.rate*100).toFixed(2));
                    $('#lastLoginIp').val(res.data.lastLoginIp);
                    $('#lastLoginTime').val(res.data.lastLoginTime);
                    $('#createTime').val(res.data.createTime);
                    $('#updateTime').val(res.data.updateTime);
                    $('#remark').val(res.data.remark);
                    form.render();
                }
            }
        })

        $(".layui-form input").each(function () {

            $(this).attr("disabled", "disabled");
        });

        form.on('submit(addBtn)', function(data) {
            admin.req({
                type: "POST",
                url: layui.setter.baseUrl + '/user/edit',
                data: data.field,
                success: function(res){
                    if(res.code == 0) {
                        layer.alert(res.msg, {title: "提示"}, function(index){
                            layer.close(index);
                            location.href = layui.setter.baseLocal + 'user/list';
                        });
                    }
                }
            });
        });
        form.render();
    })
</script>